home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor1 / pong.doc < prev    next >
Text File  |  1995-03-31  |  10KB  |  198 lines

  1. (Comp.sys.handhelds) 
  2. Item: 898 by vervalin at AUSTIN.LOCKHEED.COM 
  3. Author: [Paul Vervalin] 
  4.   Subj: PONG for HP48SX 
  5.   Keyw: games HP48SX 
  6.   Date: Sat Oct 13 1990 09:54  
  7.  
  8.    OK folks here it is!  PONG for the HP48SX written in CHIP-48. 
  9.    Some things you should know before you start playing are... 
  10.  
  11.    1)  This is my first attempt at programming in CHIP-48, so I  
  12.        know there are probably a few things that could have been 
  13.        done better. [see improved version, PONG2.  jkh] 
  14.    2)  The game never ends.  It keeps score, but only up to 9 for 
  15.        each player, then it will roll over to 0.  Sorry, its the 
  16.        only way I could think of to do it.  So, you have to play 
  17.        whoever gets to a number first, wins. 
  18.    3)  It is kind of slow, but then there are two paddles and ball 
  19.        moving around all at once. 
  20.    4)  The player who got the last point gets the serve... 
  21.    5)  Keys 7 and 4 (on the HP48) control the up and down of the  
  22.        left player and the / and * keys control the up and down of 
  23.        the right player. 
  24.  
  25.    I think that's about it, so have fun!   
  26.   
  27.         You need ASC-> to convert it to the binary string that CHIP-48 
  28.    can read. 
  29.  
  30. ==============================cut here================================== 
  31. %%HP: T(3)A(D)F(.); 
  32. "C2A20DE100A600B6C0C6F3D6C046B156002A8EAD6BCD6DE600222D6610861006 
  33. 080F510F70030021E17C71778096FF2AEE6D172A8EAD6BCD6D06100E1AB7EF06 
  34. 400E1AB72006F1B820AD6B06C00E1AD7EF06D00E1AD72006F1D820CD6D2AEE6D 
  35. 176848784906F3682016F17821640021C764F3216874F196FF740096106D1721 
  36. E2861036100807085B21E886FF36A00807085DF310216A16200851F31021EB08 
  37. 51F31021CC0851F310216C06020F81222DE843222D66E33310661086FF331086 
  38. 1021A197FF94EF96FF21CC97109420961006400F8121072A0FEF332F561F9246 
  39. B156004D5547502F924D5500EE0808080808080800000000004FD6" 
  40. ==============================cut here================================== 
  41.  
  42. This is a detailed breakdown of the game, sooooooo, if anybody wants to 
  43. make it better, or change it in some way, it might be a little easier. 
  44. Also, about half of the code was in some way extracted from the BRIX 
  45. program.  So, thanks to whoever wrote the original BRIX game. 
  46. [It was by Andreas Gustafsson.  -jkh-] 
  47.  
  48. Registers 
  49. --------- 
  50. V0-V3  are scratch registers 
  51. V4     X coord. of score 
  52. V5     Y coord. of score 
  53. V6     X coord. of ball 
  54. V7     Y coord. of ball 
  55. V8     X direction of ball motion 
  56. V9     Y direction of ball motion 
  57. VA     X coord. of right player paddle 
  58. VB     Y coord. of right player paddle 
  59. VC     X coord. of left player paddle 
  60. VD     Y coord. of left player paddle 
  61. VE     Score 
  62. VF     collision detection 
  63.  
  64. ADDRESS (all CHIP-48 programs start at 200 (hex) and increase by 2's) 
  65. -------------- 
  66.   200      6A00  VA=00     set player A (left side) X coord. 
  67.            6B0C  VB=0C     set player A Y coord. 
  68.            6C3F  VC=3F     set player B (right side) X coord. 
  69.            6D0C  VD=0C     set player B Y coord. 
  70.            641B  V4=1b     set score X coord. 
  71.            6500  V5=00     set score Y coord. 
  72.            A2E8  I=***     get address of paddle sprite 
  73.            DAB6            draw paddle at location VA VB 6 bytes 
  74.            DCD6            draw paddle at location VC VD 6 bytes 
  75.            6E00  VE=00     set score to 00 
  76.            22D2  gosub *** Score: 
  77.            6601  V6=01     set X coord. of ball to 01 
  78.            6801  V8=01     set ball X direction to right 
  79. Big Loop:  6080  V0=80     set V0=delay before ball launch 
  80.            F015  DT=V0     set delay timer 
  81. DT loop:   F007  V0=DT     read delay timer into V0 
  82.            3000            skip next instruction if V0=00 
  83.            121E  jump ***  DT loop: 
  84.            C717  V7=**     set Y coord. to rand # AND 17 (0-23) 
  85.            7708  V7=V7+08  so Y coord. is (8-31) 
  86.            69FF  V9=FF     set ball Y direction to up 
  87.            A2EE  I=***     get address of ball sprite 
  88.            D671            draw ball at location V6 V7 1 byte 
  89. Padl loop: A2E8  I=***     get address of paddle sprite 
  90.            DAB6            draw paddle at location VA VB 6 bytes 
  91.            DCD6            draw paddle at location VC VD 6 bytes 
  92.            6001  V0=01     set V0 to KEY 1 
  93.            E0A1            skip next instruction if KEY in V0 is pressed 
  94.            7BFE  VB=VB+FE  subtract 2 from Y coord. of paddle A 
  95.            6004  V0=04     set V0 to KEY 4 
  96.            E0A1            skip next instruction if KEY in V0 is pressed 
  97.            7B02  VB=VB+02  add 2 to Y coord. of paddle A 
  98.            601F  V0=1F     set V0 to max Y coord. 
  99.            8B02  VB=VB&V0  AND VB with V0 
  100.            DAB6            draw paddle at location VA VB 6 bytes 
  101.            600C  V0=0C     set V0 to KEY C 
  102.            E0A1            skip next instruction if KEY in V0 is pressed 
  103.            7DFE  VD=VD+FE  subtract 2 from Y coord. of paddle B 
  104.            600D  V0=0D     set V0 to KEY D 
  105.            E0A1            skip next instruction if KEY in V0 is pressed  
  106.            7D02  VD=VD+02  add 2 to Y coord. of paddle B 
  107.            601F  V0=1F     set V0 to max Y coord. 
  108.            8D02  VD=VD&V0  AND VD with V0 
  109.            DCD6            draw paddle at location VC VD 6 bytes 
  110.            A2EE  I=***     get address of ball sprite 
  111.            D671            draw ball at location V6 V7 1 byte 
  112.            8684  V6=V6+V8  move ball in X direction 
  113.            8794  V7=V7+V9  move ball in Y direction 
  114.            603F  V0=3F     set V0 to max X location 
  115.            8602  V6=V6&V0  AND V6 with V0 
  116.            611F  V1=1F     set V1 to max Y location 
  117.            8712  V7=V7&V0  AND V7 with V0 
  118.            4600            skip next instruction if ball not at left 
  119.            127C  jump ***  Leftside:  left side handler 
  120.            463F            skip next instruction if ball not at right 
  121.            1286  jump ***  Rightside: right side handler 
  122. Ball Loop: 471F            skip next instruction if ball not at bottom 
  123.            69FF  V9=FF     set Y direction to up 
  124.            4700            skip next instruction if ball not at top 
  125.            6901  V9=01     set Y direction to down 
  126.            D671            draw ball at location V6 V7 1 byte 
  127.            122E  jump ***  Padl loop: 
  128. Leftside:  6801  V8=01     set X direction to right 
  129.            6301  V3=01     set V2 to 1 in case left misses ball 
  130.            8070  V0=V7     set V0 to V7 Y coord. of ball 
  131.            80B5  V0=V0-VB  subtract position of paddle from ball 
  132.            128E  jump ***  Pad Coll: 
  133. Rightside: 68FF  V8=FF     set X direction to left 
  134.            630A  V3=0A     set V2 to 0A (10) in case right misses ball 
  135.            8070  V0=V7     set V0 to V7 Y coord. of ball 
  136.            80D5  V0=V0-VD  subtract position of paddle from ball 
  137. Pad Coll:  3F01            skip next instruction if ball not above paddle 
  138.            12A6  jump ***  Ball Lost: 
  139.            6102  V1=02     set V1 to 02 
  140.            8015  V0=V0-V1  subtract V1 from V0 
  141.            3F01            skip next instr. if ball not at top of paddle 
  142.            12BE  jump ***  Ball Top: 
  143.            8015  V0=V0-V1  subtract another 2 from V0 
  144.            3F01            skip next instr. if ball not at middle of paddle 
  145.            12CC  jump ***  Pad Hit:  Ball in middle of paddle 
  146.            8015  V0=V0-V1  subtract another 2 from V0 
  147.            3F01            skip next instr. if ball not at bottom of paddle 
  148.            12C6  jump ***  Ball Bot: 
  149. Ball Lost: 6020  V0=20     set lost ball beep delay 
  150.            F018            beep for lost ball 
  151.            22D2  gosub *** Score:  erase previous score 
  152.            8E34  VE=VE+V3  add 1 or 10 to score depending on V3 
  153.            22D2  gosub *** Score:  write new score 
  154.            663E  V6=3E     set ball X coord. to right side 
  155.            3301            skip next instr. if right player got point 
  156.            6601            set ball X coord. to left side 
  157.            68FF            set direction to left 
  158.            3301            skip next instr. if right player got point 
  159.            6801            set direction to right 
  160.            121A  jump ***  Big Loop: 
  161. Ball Top:  79FF  V9=V9+FF  subtract 1 from V9, ball Y direction 
  162.            49FE            skip next instr. if V9 != FE (-2) 
  163.            69FF  V9=FF     set V9=FF (-1) 
  164.            12CC  jump ***  Pad Hit: 
  165. Ball Bot:  7901  V9=V9+01  add 1 to V9, ball Y direction 
  166.            4902            skip next instr. if V9 != 02 
  167.            6901  V9=01     set V9=01 
  168. Pad Hit:   6004  V0=04     set beep for paddle hit 
  169.            F018  ST=V0     sound beep 
  170.            1270  jump ***  Ball Loop: 
  171. Score:     A2F0  I=***     get address of Score 
  172.            FE33 
  173.            F265 
  174.            F129 
  175.            641B 
  176.            6500 
  177.            D455 
  178.            7405 
  179.            F229 
  180.            D455 
  181.            00EE 
  182. Paddle:    8080 
  183.            8080 
  184.            8080 
  185. Ball:      8000 
  186. Score:     0000 
  187.            0000 
  188.  
  189.                                                    _____        _______        
  190.  
  191. *********************************    HP48SX       / ___ \      /__    (\      
  192. *                               * .----------.    ||   ||     /( _)  z) \    
  193. * Paul Vervalin                 * |]]]]]]].-.|    ||___||    |. V__ (_ \/|    
  194. *                               * |]]]]]]]| ||    \_____/    |   ( ) ) | |    
  195. * vervalin@AUSTIN.LOCKHEED.COM  * |]]]]]]]| ||   .-------.   [   |/  (_/ |   
  196. *                               * |]]]]]]]`-']---[ AMIGA ]__/ \  `.     /      
  197. ********************************* `----------'   `-------'     \_______/ 
  198.